package com.util.filter;

import java.util.Map;

public class LoginFilter extends AbstractInterceptor{
	public String intercept(ActionInvocation invocation) throws Exception
	{
		ActionContext ctx = invocation.getInvocationContext();
		Map<String, Object> session = ctx.getSession();
		Integer power = (Integer) session.get("power");
		if(power == null){
			ctx.put("tip" , "你还不是会员");
			return "toLogin"; 
		} else{
			ctx.put("power", power);
			Integer id = (Integer) session.get("id");
			ctx.put("tid", id);
			ctx.put("sid", id);
			String name = (String) session.get("name");
			ctx.put("name",name);
		}
		
		return invocation.invoke();
	}
}
